#coding: utf-8
class CulturalHeritage::CulturalHeritageAvatar < ActiveRecord::Base
  has_attached_file :avatar
  validates :title, :presence => {:message => "El Titulo es requerido"}
  validates :avatar_file_name, :presence => {:message => "La foto requerida"}
  default_scope where("deleted = 0")
  validates_attachment_content_type :avatar, :content_type => /image/

  def self.count_cultural_heritage_dependencies(id)
      return find(:all,:conditions=>["cultural_heritage_cultural_heritage_avatars.cultural_heritage = ? and (cultural_heritage_cultural_heritage_avatars.deleted = ?) ",id,0],:select=>"count(*) as 'cultural_heritage_avatars'")[0].cultural_heritage_avatars.to_i
  end
end
